Skip to main content
Version: 4.4

Create a requirements.txt

To install python libraries for your model you need a requirements.txt file. There are multiple ways to do this. This how-to shows you the most common ones.

Manually

You can manually create a requirements.txt file by simply creating a flat text file that contains the names of the libraries you require. For example if you are using the pandas library you would write the following in your requirements.txt:

pandas

This is the most basic version, but not very stable and future-proof. It is way better if you also specify versions. Without a version we always get the latest one. Because not all library versions are compatible this could lead to big problems! You can specify a version by pinning it:

pandas==1.0.0 # exactly installs 1.0.0

Also make sure these library versions are the same as the ones you use locally, so that your Katonic deployment and local environment are in sync! You can read more about the possibilities of the requirements.txt file here.

Using pip freeze

A different approach would be using the command pip freeze to automatically generate a requirements.txt file based on your local environment.

For example if you have pandas version 1.0.0 installed. Just simply run in your terminal pip freeze > requirements.txt and you will end up with the following file:

pandas==1.0.0 # exactly installs 1.0.0